//
//  FLMOrderSearchView.m
//  FLMSuperS
//
//  Created by xiaoyang on 16/9/16.
//  Copyright © 2016年 FaLaoMiaoNetworkTechnologyCo. All rights reserved.
//

#import "FLMOrderSearchView.h"

@interface FLMOrderSearchView()

@property (nonatomic,strong) UITextField *searchText;
@property (nonatomic,strong) UIButton *searchButton;
@property (nonatomic,strong) UIView *bottomline;

@end

@implementation FLMOrderSearchView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self layoutUI];
    }
    return self;
}

- (void)layoutUI
{
    if (!_searchText) {
        _searchText = [[UITextField alloc]init];
        _searchText.placeholder = @"请输入订单号";
        _searchText.font = font14;
        [self addSubview:_searchText];
        [_searchText mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(0);
            make.left.mas_equalTo(10);
            make.right.mas_equalTo(-80);
        }];
    }
    
    if (!_searchButton) {
        _searchButton = [[UIButton alloc]init];
        [_searchButton setTitle:@"搜索" forState:UIControlStateNormal];
        _searchButton.titleLabel.font = font14;
        _searchButton.backgroundColor = orange;
        [_searchButton addTarget:self action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_searchButton];
        [_searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.right.mas_equalTo(0);
            make.width.mas_equalTo(80);
            
            
        }];
    }
    
    if (!_bottomline) {
        _bottomline = [[UIView alloc]init];
        _bottomline.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
        [self addSubview:_bottomline];
        [_bottomline mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
        }];
    }
}

- (void)searchAction
{
    if (self.searchBlock) {
        self.searchBlock(_searchText);
    }
}

@end
